package com.lkd.controller;

import com.lkd.dto.RegionDto;
import com.lkd.dto.RegionPageDto;
import com.lkd.entity.Region;
import com.lkd.result.PageBean;
import com.lkd.result.Result;
import com.lkd.service.RegionService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/api/vm-service/region")
public class RegionController {

    @Autowired
    private RegionService regionService;

    //区域搜索，并用PageBean进行分页
    @GetMapping("/search")
    public Result getList(RegionPageDto regionPageDto) {
        PageBean pageBean = regionService.getList(regionPageDto);
        return Result.success(pageBean);
    }
    //新增区域
    @PostMapping
    public boolean save(@RequestBody Region region) {
        Boolean result = regionService.save(region);
        return result;
    }
    //修改区域
    @PutMapping
    public Result update(@RequestBody RegionDto regionDto) {
        Boolean result = regionService.update(regionDto);
        return Result.success(result);
    }


}

